package com.travel.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.travel.bean.User;



public class LoginInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request,HttpServletResponse response,Object handler) throws Exception{
		
		HttpSession session = request.getSession();
		
		User user = (User)session.getAttribute("user");
		System.out.println(user.getName());
		if(null == user){
			response.sendRedirect(request.getContextPath()+"/comm/login.html");
			return false;
		}
		return true;
	}
}
